package com.fushenlan.epidemicControl.service.Impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fushenlan.epidemicControl.mapper.AreaMapper;
import com.fushenlan.epidemicControl.mapper.BuildInfoMapper;
import com.fushenlan.epidemicControl.mapper.NeighborhoodInfoMapper;
import com.fushenlan.epidemicControl.service.AreaService;
import com.fushenlan.po.Area;
import com.fushenlan.po.BuildingInfoDO;
import com.fushenlan.po.NeighborhoodInfoDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AreaServiceImpl implements AreaService {

    @Autowired
    private AreaMapper areaMapper;

    @Autowired
    private NeighborhoodInfoMapper neighborhoodInfoMapper;

    @Autowired
    private BuildInfoMapper buildInfoMapper;


    /**
     * 获取所有区域数据  通过deep
     * deep   0 省    1 市   2 县  3 镇
     *
     * @param deep
     * @return
     */
    @Override
    public List<Area> findAreaByDeep(String deep) {
        return areaMapper.findAreaByDeep(deep);
    }

    /**
     * 根据输入的条件获取区域数据
     *
     * @param area
     * @return
     */
    @Override
    public List<Area> findList(Area area) {
        return areaMapper.findList(area);
    }

    /**
     * @param streetCode
     * @return
     */
    @Override
    public List<NeighborhoodInfoDO> queryListByStreetCode(String streetCode) {
        QueryWrapper<NeighborhoodInfoDO> wrapper = new QueryWrapper<>();
        wrapper.eq("streetCode", streetCode);
        return neighborhoodInfoMapper.selectList(wrapper);
    }

    /**
     * @param id
     * @return
     */
    @Override
    public List<BuildingInfoDO> queryBuildingInfos(String id, String deep) {
        QueryWrapper<BuildingInfoDO> wrapper = new QueryWrapper<>();
        wrapper.eq("parentId", id).eq("level", deep);
        List<BuildingInfoDO> list = buildInfoMapper.selectList(wrapper);
        return list;
    }


}
